import { g_db } from 'db/state';

const do_select = (stepnum, step, umd, watch) => {
    const box_sn = g_db.box();

    if (!box_sn) {
        alert("请先扫描箱子编码");

        umd.clear();

        watch.startWatch();
        return;
    }

    umd.set_st("wait");
    umd.openBox(true);

    watch.startWatch();
};

const do_box_style = (stepnum, step, umd, watch) => {
    const box_sn = g_db.box();

    if (!box_sn) {
        alert("请先扫描箱子编码");

        umd.clear();

        watch.startWatch();
        return;
    }

    umd.set_st("wait");
    umd.openBoxSt(true);

    watch.startWatch();
};

const do_select_tp = (stepnum, step, umd, watch) => {
    const box_sn = g_db.box();

    if (!box_sn) {
        alert("请先扫描箱子编码");

        umd.clear();

        watch.startWatch();
        return;
    }

    umd.set_st("wait");
    umd.openBoxTp(true);

    watch.startWatch();
};

const do_box_good = (stepnum, step, umd, watch) => {
    const box_sn = g_db.box();

    if (!box_sn) {
        alert("请先扫描箱子编码");

        umd.clear();

        watch.startWatch();
        return;
    }

    umd.set_st("wait");
    umd.openBoxGood(true);

    watch.startWatch();
};


const do_restore = (stepnum, step, umd, watch) => {
    const box_sn = g_db.box();

    if (!box_sn) {
        alert("请先扫描箱子编码");

        umd.clear();

        watch.startWatch();
        return;
    }

    umd.set_st("wait");
    umd.openStore(true);

    watch.startWatch();
};

export {do_restore, do_select_tp, do_box_style, do_select, do_box_good};
